/*
* highlight 1.0(高亮显示文本)
* Copyright (C) 2013 Peng yuanjun
* Date:2013-01-29
* 自己学习jquery插件开发时,编写的第一个插件,参考http://www.iteye.com/topic/545971,参考http://www.tripfox.com.cn/node/64
* 注意事项：
* $.extend(object)方法,参考http://www.cnblogs.com/RascallySnake/archive/2010/05/07/1729563.html
*/

(function($){
	$.fn.highlight = function(options){
		//debug(this);
		var opts = $.extend({},$.fn.highlight.defaults,options);
		return this.each(function(){
			$this = $(this);
			var o = $.meta?$.extend({},opts,$this.data()):opts;
			$this.css({
				 backgroundColor: o.background,
				 color: o.foreground
			});
			var markup = $this.html();
			markup = $.fn.highlight.format(markup);
			$this.html(markup);
		});
	}
	//私有函数
	function debug(obj){
		alert(obj);
	};
	//定义暴露的函数
	$.fn.highlight.format = function(txt){
		return '<strong>'+txt+'</strong>';
	};
	//定义暴露的defaults
	$.fn.highlight.defaults = {
		foreground:'red',
		background:'yellow'
	};
})(jQuery)